﻿<!--***********************************************************************************

   Extended WPF Toolkit

   Copyright (C) 2007-2013 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   For more features, controls, and fast professional support,
   pick up the Plus Edition at http://xceed.com/wpf_toolkit

   Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids

  **********************************************************************************-->

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes"
                    xmlns:local="clr-namespace:Xceed.Wpf.Toolkit"
                    xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Converters"
                    xmlns:coreConv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters">

   <coreConv:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter" />

    <!-- //#TODODOC
         Repeat Button - This is used by RangeSlider for the LowerRange, Range, and HigherRange buttons -->
   <Style x:Key="DefaultRangeStyle"
          TargetType="{x:Type RepeatButton}">
      <Setter Property="Focusable"
              Value="False" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
               <Grid>
                  <Rectangle x:Name="MainBorder"
                             Fill="{TemplateBinding Background}" />
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!--//##TODODOC-->
   <!--Since a thumb is pretty small, we put a bigger visual clue
   outside the thumb bounds to give the user a hint where the focus is-->
   <Style x:Key="ThumbFocusVisualStyle">
      <Setter Property="Control.Template">
         <Setter.Value>
            <ControlTemplate>
               <Rectangle Margin="-2"
                          StrokeThickness="1"
                          Stroke="Black"
                          StrokeDashArray="1 2" />
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- ********************** -->
    <!-- Thumb Template    -->
    <!-- ********************** -->
   <ControlTemplate x:Key="ThumbTemplate"
                    TargetType="{x:Type Thumb}">
      <Grid>
         <Rectangle x:Name="BackgroundFadingRect"
                    Fill="Black"
                    Width="11"
                    Height="20" />
         <Rectangle x:Name="MainBorder"
                    Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background, TargetNullValue=#FFF0F0F0}"
                    StrokeThickness="1"
                    Stroke="#FFACACAC"
                    Opacity="1"
                    Width="11"
                    Height="20"
                    ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type Slider}}, Path=Value, StringFormat=\{0:00.00\}}"
                    SnapsToDevicePixels="True" />
      </Grid>
      <ControlTemplate.Triggers>
         <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background, Converter={StaticResource SolidColorBrushToColorConverter}}"
                      Value="Transparent">
            <Setter Property="Visibility"
                    TargetName="BackgroundFadingRect"
                    Value="Collapsed" />
         </DataTrigger>
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter Property="Opacity"
                    TargetName="MainBorder"
                    Value="0.75" />
         </Trigger>
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"
                          Value="{x:Null}" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
                          Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Opacity"
                    TargetName="MainBorder"
                    Value="1" />
            <Setter Property="Stroke"
                    TargetName="MainBorder"
                    Value="#FF7EB4EA" />
            <Setter Property="Fill"
                    TargetName="MainBorder"
                    Value="#FFDCECFC" />
         </MultiDataTrigger>

         <Trigger Property="IsEnabled"
                  Value="False">
            <Setter Property="Opacity"
                    TargetName="MainBorder"
                    Value="1" />
            <Setter Property="Stroke"
                    TargetName="MainBorder"
                    Value="#FFD9D9D9" />
            <Setter Property="Fill"
                    TargetName="MainBorder"
                    Value="#FFF0F0F0" />
         </Trigger>
         <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Slider}}, Path=Orientation}"
                      Value="Vertical">
            <Setter TargetName="MainBorder"
                    Property="Width"
                    Value="20" />
            <Setter TargetName="MainBorder"
                    Property="Height"
                    Value="11" />
            <Setter TargetName="BackgroundFadingRect"
                    Property="Width"
                    Value="20" />
            <Setter TargetName="BackgroundFadingRect"
                    Property="Height"
                    Value="11" />
         </DataTrigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

    <!-- ********************** -->
    <!-- Slider Template     -->
    <!-- ********************** -->
   <ControlTemplate x:Key="SliderTemplate"
                    TargetType="{x:Type Slider}">
      <Border SnapsToDevicePixels="true"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}">
            <Track x:Name="PART_Track"
                   Orientation="{TemplateBinding Orientation}"
                   Grid.Row="1">
               <Track.Thumb>
                  <Thumb x:Name="Thumb"
                         Focusable="True"
                         FocusVisualStyle="{StaticResource ThumbFocusVisualStyle}"
                         Background="{TemplateBinding Background}"
                         Template="{StaticResource ThumbTemplate}">
                  </Thumb>
               </Track.Thumb>
            </Track>
      </Border>
   </ControlTemplate>

    <!-- ********************** -->
    <!-- Vertical RangeSlider Template -->
    <!-- ********************** -->
   <ControlTemplate x:Key="VerticalRangeSlider"
                    TargetType="{x:Type local:RangeSlider}">
      <Border BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              Background="{TemplateBinding Background}">
         <Grid HorizontalAlignment="Left"
               VerticalAlignment="Top">
            <!-- //#TODODOC 
             Get Thumbs's height to set the good RangeSlider height.-->
            <Grid.RowDefinitions>
               <RowDefinition Height="11" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="11" />
            </Grid.RowDefinitions>

            <Border Grid.Row="1"
                    Grid.RowSpan="3"
                    BorderThickness="1"
                    BorderBrush="#FFD6D6D6"
                    Background="#FFE7EAEA"
                    VerticalAlignment="Stretch"
                    HorizontalAlignment="Center"
                    Width="4" />

            <RepeatButton x:Name="PART_LowerRange"
                          Height="{TemplateBinding LowerRangeWidth}"
                          Grid.Row="3"
                          Background="{TemplateBinding LowerRangeBackground}"
                          Style="{Binding LowerRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                          SnapsToDevicePixels="True" />

            <RepeatButton Height="{TemplateBinding RangeWidth}"
                          Grid.Row="2"
                          Background="{TemplateBinding RangeBackground}"
                          Style="{Binding RangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                          SnapsToDevicePixels="True" />

            <RepeatButton x:Name="PART_HigherRange"
                          Height="{TemplateBinding HigherRangeWidth}"
                          Grid.Row="1"
                          Background="{TemplateBinding HigherRangeBackground}"
                          Style="{Binding HigherRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                          SnapsToDevicePixels="True" />

            <!-- Margin is set in CodeBehind, based on HigherSlider's Thumb Height -->
            <Slider x:Name="PART_LowerSlider"
                    Orientation="Vertical"
                    Grid.RowSpan="5"
                    Focusable="False"
                    Background="{TemplateBinding LowerThumbBackground}"
                    Template="{StaticResource SliderTemplate}">
            </Slider>

            <!-- Margin is set in CodeBehind, based on LowerSlider's Thumb width -->
            <Slider x:Name="PART_HigherSlider"
                    Grid.RowSpan="5"
                    Orientation="Vertical"
                    Focusable="False"
                    Background="{TemplateBinding HigherThumbBackground}"
                    Template="{StaticResource SliderTemplate}">
            </Slider>
         </Grid>
      </Border>
   </ControlTemplate>

    <!-- ********************** -->
    <!-- RangeSlider Style -->
    <!-- ********************** -->
   <Style TargetType="{x:Type local:RangeSlider}">
      <Setter Property="IsTabStop"
              Value="False" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:RangeSlider}">
               <Border BorderBrush="{TemplateBinding BorderBrush}"
                       BorderThickness="{TemplateBinding BorderThickness}"
                       Background="{TemplateBinding Background}">
                  <Grid HorizontalAlignment="Left"
                        VerticalAlignment="Top">
                     <!-- //#TODODOC 
                        Get Thumbs's width to set the good RangeSlider width.-->
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="11" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="11" />
                     </Grid.ColumnDefinitions>

                     <Border Grid.Row="1"
                             Grid.Column="1"
                             Grid.ColumnSpan="3"
                             BorderThickness="1"
                             BorderBrush="#FFD6D6D6"
                             Background="#FFE7EAEA"
                             VerticalAlignment="Center"
                             Height="4" />

                     <RepeatButton x:Name="PART_LowerRange"
                                   Width="{TemplateBinding LowerRangeWidth}"
                                   Grid.Column="1"
                                   Grid.Row="1"
                                   Background="{TemplateBinding LowerRangeBackground}"
                                   Style="{Binding LowerRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                                   SnapsToDevicePixels="True" />

                     <RepeatButton Width="{TemplateBinding RangeWidth}"
                                   Grid.Row="1"
                                   Grid.Column="2"
                                   Background="{TemplateBinding RangeBackground}"
                                   Style="{Binding RangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                                   SnapsToDevicePixels="True" />

                     <RepeatButton x:Name="PART_HigherRange"
                                   Width="{TemplateBinding HigherRangeWidth}"
                                   Grid.Row="1"
                                   Grid.Column="3"
                                   Background="{TemplateBinding HigherRangeBackground}"
                                   Style="{Binding HigherRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                                   SnapsToDevicePixels="True" />

                     <!-- Margin is set in CodeBehind, based on HigherSlider's Thumb width -->
                     <Slider x:Name="PART_LowerSlider"
                             Grid.Row="1"
                             Grid.ColumnSpan="5"
                             Focusable="False"
                             Background="{TemplateBinding LowerThumbBackground}"
                             Template="{StaticResource SliderTemplate}">
                     </Slider>

                     <!-- Margin is set in CodeBehind, based on LowerSlider's Thumb width -->
                     <Slider x:Name="PART_HigherSlider"
                             Grid.Row="1"
                             Grid.ColumnSpan="5"
                             Focusable="False"
                             Background="{TemplateBinding HigherThumbBackground}"
                             Template="{StaticResource SliderTemplate}">
                     </Slider>
                  </Grid>
               </Border>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
      <Style.Triggers>
         <Trigger Property="Orientation"
                  Value="Vertical">
            <Setter Property="Template"
                    Value="{StaticResource VerticalRangeSlider}" />
         </Trigger>
      </Style.Triggers>


   </Style>

</ResourceDictionary>
